Skip to content

Conversation

@kabakakao
Copy link

@kabakakao kabakakao commented Jan 8, 2026

Use European Souvereign Cloud specific Endpoints if neccessary

Fixes: aws/aws-for-fluent-bit#1057

Testing
Before we can approve your change; please submit the following in a comment:

  • Added a TestCase

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • New Features

    • Improved AWS endpoint construction to use dynamic domain suffixes for standard, China, and EU Sovereign Cloud regions, producing correct regional endpoints.
  • Tests

    • Added tests to validate EU Sovereign Cloud and China regional endpoint behavior.
  • Bug Fixes

    • Enhanced endpoint length calculation and validation to prevent buffer/formatting failures.

✏️ Tip: You can customize this high-level summary in your review settings.

@kabakakao kabakakao requested a review from a team as a code owner January 8, 2026 06:44
@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Endpoint construction now selects a domain suffix dynamically: standard ".amazonaws.com", China ".amazonaws.com.cn" for cn-north-1/cn-northwest-1, and EU Sovereign Cloud ".amazonaws.eu" for regions starting with eusc-. Length calculation and snprintf usage updated; tests extended for EU suffix.

Changes

Cohort / File(s) Summary
AWS Endpoint Configuration
src/aws/flb_aws_util.c
Replaced hardcoded final domain with selectable suffixes (.amazonaws.com, .amazonaws.com.cn, .amazonaws.eu); added region checks for China and EU sovereign cloud (cn-*, eusc-*); recomputed buffer length; updated snprintf call and error handling; removed post-processing for China .cn.
Endpoint Test Coverage
tests/internal/aws_util.c
Added test for EU Sovereign Cloud region (eusc-de-east-1cloudwatch.eusc-de-east-1.amazonaws.eu); retained tests for ap-south-1 and cn-north-1; ensured endpoint memory freeing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I munched a host and changed its tail,

swapped .com for new clouds on the trail.
In China, EU, or usual sun,
endpoints hop, their work now done.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: switching AWS endpoints for European Sovereign Cloud, matching the core objective of fixing endpoint URLs for this region.
Linked Issues check ✅ Passed The PR implementation correctly addresses issue #1057 by adding detection for eusc- regions to use .amazonaws.eu suffix instead of .amazonaws.com, fixing the incorrect endpoint URLs.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing European Sovereign Cloud endpoint handling; endpoint formatting logic updates and new test case are within stated objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/aws/flb_aws_util.c (2)

86-93: Region-to-suffix mapping correctly implements EU Sovereign Cloud support.

The logic properly routes:

  • China regions (cn-north-1, cn-northwest-1) → .amazonaws.com.cn
  • EU Sovereign Cloud (eusc-de-east-1) → .amazonaws.eu
  • All other regions → .amazonaws.com (default)
💡 Optional: Consider a lookup table for future scalability

If additional EU Sovereign Cloud regions are added in the future, a lookup table or pattern-based approach could improve maintainability:

+static const char* get_domain_suffix(const char* region) {
+    if (strcmp(region, "cn-north-1") == 0 || strcmp(region, "cn-northwest-1") == 0) {
+        return AWS_SERVICE_ENDPOINT_SUFFIX_COM_CN;
+    }
+    if (strncmp(region, "eusc-", 5) == 0) {  /* Match all eusc-* regions */
+        return AWS_SERVICE_ENDPOINT_SUFFIX_EU;
+    }
+    return AWS_SERVICE_ENDPOINT_SUFFIX_COM;
+}

However, the current hardcoded approach is acceptable for the known regions.


107-112: Consider checking for snprintf truncation.

The current error handling only checks for encoding errors (bytes < 0). While truncation shouldn't occur due to the correct length calculation, defensive coding would also verify that bytes < len to catch any unexpected truncation.

🛡️ More robust snprintf error handling
-    bytes = snprintf(endpoint, len, AWS_SERVICE_ENDPOINT_FORMAT, service, region, domain_suffix);
-    if (bytes < 0) {
+    bytes = snprintf(endpoint, len, AWS_SERVICE_ENDPOINT_FORMAT, service, region, domain_suffix);
+    if (bytes < 0 || bytes >= len) {
         flb_errno();
         flb_free(endpoint);
         return NULL;
     }

This guards against both encoding errors and unexpected truncation.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e19e07e and c77dc5a.

📒 Files selected for processing (2)
  • src/aws/flb_aws_util.c
  • tests/internal/aws_util.c
🧰 Additional context used
🧬 Code graph analysis (2)
src/aws/flb_aws_util.c (1)
include/fluent-bit/flb_mem.h (1)
  • flb_calloc (84-96)
tests/internal/aws_util.c (2)
src/aws/flb_aws_util.c (1)
  • flb_aws_endpoint (78-116)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
🔇 Additional comments (3)
src/aws/flb_aws_util.c (2)

36-39: LGTM! Clear parameterization of endpoint format.

The new constants cleanly separate the endpoint format from domain suffixes, enabling support for standard (.com), China (.com.cn), and EU Sovereign Cloud (.eu) regions.


95-99: LGTM! Length calculation is accurate.

The calculation correctly accounts for all components in the format "%s.%s%s":

  • Service name length
  • Dot separator (1 byte)
  • Region name length
  • Domain suffix length
  • Null terminator (1 byte)
tests/internal/aws_util.c (1)

166-172: LGTM! Test case properly validates EU Sovereign Cloud endpoint.

The test correctly verifies that region eusc-de-east-1 produces the endpoint cloudwatch.eusc-de-east-1.amazonaws.eu, directly addressing the issue described in #1057. Memory management and test structure follow the established pattern.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/aws/flb_aws_util.c (1)

91-93: Consider prefix-based matching for EU Sovereign Cloud regions.

The current implementation correctly handles the eusc-de-east-1 region as specified in the issue. However, if AWS introduces additional EU Sovereign Cloud regions (which would likely follow the eusc-* naming pattern), each would require a code change.

♻️ Proposed refactor for scalability
-    else if (strcmp("eusc-de-east-1", region) == 0) {
+    else if (strncmp(region, "eusc-", 5) == 0) {
         domain_suffix = AWS_SERVICE_ENDPOINT_SUFFIX_EU;
     }

This approach would automatically support any future EU Sovereign Cloud regions without requiring code changes.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c77dc5a and 86807e7.

📒 Files selected for processing (2)
  • src/aws/flb_aws_util.c
  • tests/internal/aws_util.c
🧰 Additional context used
🧬 Code graph analysis (2)
src/aws/flb_aws_util.c (1)
include/fluent-bit/flb_mem.h (1)
  • flb_calloc (84-96)
tests/internal/aws_util.c (2)
src/aws/flb_aws_util.c (1)
  • flb_aws_endpoint (78-116)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
🔇 Additional comments (7)
src/aws/flb_aws_util.c (6)

36-39: LGTM! Clean constant definitions for domain suffixes.

The introduction of separate domain suffix constants and the updated format string enables flexible endpoint construction for different AWS partitions (standard, China, EU Sovereign Cloud).


76-77: LGTM! Comment accurately reflects the updated endpoint format.


87-90: LGTM! China region handling is correct and complete.

The code properly handles both China regions (cn-north-1 and cn-northwest-1) by using the .amazonaws.com.cn domain suffix.


95-99: LGTM! Length calculation is correct and clear.

The calculation properly accounts for all endpoint components (service, dot separator, region, domain suffix, and null terminator).


101-105: LGTM! Memory allocation and error handling are correct.


107-112: LGTM! Endpoint construction and error handling are correct.

The snprintf call properly formats the endpoint using the selected domain suffix, and error handling ensures memory is freed on failure.

tests/internal/aws_util.c (1)

166-171: LGTM! Test coverage for EU Sovereign Cloud endpoint is excellent.

The new test case properly validates that the eusc-de-east-1 region generates the correct endpoint with the .amazonaws.eu domain suffix, as required by issue #1057. The test follows the established pattern and includes proper memory management.

#define AWS_SERVICE_ENDPOINT_FORMAT "%s.%s%s"
#define AWS_SERVICE_ENDPOINT_SUFFIX_COM ".amazonaws.com"
#define AWS_SERVICE_ENDPOINT_SUFFIX_COM_CN ".amazonaws.com.cn"
#define AWS_SERVICE_ENDPOINT_SUFFIX_EU ".amazonaws.eu"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EuSC is available as preview and will soon be publicly launched as well. logs.eusc-de-east-1.amazonaws.eu does exist

@cosmo0920
Copy link
Contributor

We need to rebase off the current master. So, could you remove merge commit and forcely push rebased your branch?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/aws/flb_aws_util.c (1)

75-77: Minor documentation clarity suggestion.

The comment notation [com(.cn)|eu] is functional but could be made clearer. Consider:

 /*
- * https://service.region.amazonaws.[com(.cn)|eu]
+ * https://service.region.amazonaws.{com|com.cn|eu}
  */

This explicitly shows the three possible domain suffixes.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 452e01e and b1532d4.

📒 Files selected for processing (2)
  • src/aws/flb_aws_util.c
  • tests/internal/aws_util.c
🧰 Additional context used
🧬 Code graph analysis (2)
tests/internal/aws_util.c (2)
src/aws/flb_aws_util.c (1)
  • flb_aws_endpoint (78-116)
include/fluent-bit/flb_mem.h (1)
  • flb_free (126-128)
src/aws/flb_aws_util.c (1)
include/fluent-bit/flb_mem.h (1)
  • flb_calloc (84-96)
🔇 Additional comments (5)
tests/internal/aws_util.c (1)

166-171: LGTM! Test case correctly validates EU Sovereign Cloud endpoint.

The test properly verifies that eusc-de-east-1 region produces the expected .amazonaws.eu domain suffix, directly addressing the issue described in #1057. Memory management is consistent with existing tests.

Consider adding an additional test case for another eusc-* region (e.g., eusc-de-west-1) to verify the prefix-based matching works for any EU Sovereign Cloud region, not just the specific one reported in the issue.

src/aws/flb_aws_util.c (4)

36-39: LGTM! Well-structured constants for endpoint construction.

The domain suffix constants are clearly named, include the leading dot appropriately, and the format string correctly represents the endpoint structure service.region{suffix}.


86-93: LGTM! Region detection logic is correct.

The implementation properly handles:

  • China regions with exact string matching (only two known regions)
  • EU Sovereign Cloud with prefix matching (eusc-) for flexibility with future regions
  • Default .amazonaws.com for all other regions

The use of strncmp with length 5 for the eusc- prefix is appropriate.


95-99: LGTM! Length calculation is correct.

The buffer size calculation properly accounts for:

  • Service name length
  • Dot separator (1 byte)
  • Region name length
  • Domain suffix length (dynamically sized)
  • Null terminator (1 byte)

107-108: LGTM! Endpoint construction and error handling are correct.

The snprintf call correctly formats the endpoint as service.region{domain_suffix}, and the error handling properly checks for both negative return values and potential truncation (bytes >= len).

@kabakakao
Copy link
Author

@cosmo0920 I have rebased from your master and now my fork reports as just 2 ahead of your master, and neither of those are merge commits, both are signed. Does this achieve what you want to?

@patrick-stephens
Copy link
Collaborator

patrick-stephens commented Jan 13, 2026

So the gist is when you specify an EU region it should use EU endpoints I believe. We should update the docs to make this clear as well.

Probably a philosophical question but should UK regions target EU or US endpoints?

@cosmo0920
Copy link
Contributor

Our commit linter complains like that:

❌ Commit 158bdfe072 failed:
Subject prefix 'feature:' does not match files changed.
Expected one of: aws:, tests:

We need to follow the linting rule.

@sparrc
Copy link

sparrc commented Jan 13, 2026

So the gist is when you specify an EU region it should use EU endpoints I believe. We should update the docs to make this clear as well.

Probably a philosophical question but should UK regions target EU or US endpoints?

Not all EU regions should use these endpoints, only EU regions that are designated as a "European Sovereign Cloud" region (currently there is only one). These regions have a unique prefix (eusc-de-east-1) versus the "regular" commercial EU regions (eu-central-1).

len += 3;
is_cn = FLB_TRUE;
/* China regions end with amazonaws.com.cn */
if (strcmp("cn-north-1", region) == 0 ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside scope of this PR, but we should probably change these to just check for the cn- prefix instead of the full region name, similar to how you've done eusc below.

@sparrc
Copy link

sparrc commented Jan 13, 2026

Probably a philosophical question but should UK regions target EU or US endpoints?

Interestingly there is a UK "iso" partition, which uses the .uk TLD, but the region name itself is prefixed with eu- 🤔

https://github.com/aws/aws-sdk-go-v2/blob/c06b95b12734b7c87e42bbcc7ce10395831c2730/internal/endpoints/awsrulesfn/partitions.json#L203C1-L221C4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Endpoint URL for European Souvereign Cloud incorrect

4 participants